﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Escape
{
    class Ceiling
    {
        RasterizerState rs = new RasterizerState();
        RasterizerState rs2 = new RasterizerState();

        Face[,] faces;

        Texture2D floorTex;

        public Ceiling(int mapWidth, int mapHeight)
        {

            floorTex = Basic.content.Load<Texture2D>("Textures\\floor");

            faces = new Face[mapWidth, mapHeight];

            for (int i = 0; i < mapWidth; i++)
            {
                for (int j = 0; j < mapHeight; j++)
                {
                    faces[i, j] = new Face(i, mapHeight - j, Mode.ceiling);
                }
            }

            rs.CullMode = CullMode.CullClockwiseFace;
            rs2.CullMode = CullMode.CullCounterClockwiseFace;
        }

        public void Render()
        {
            Basic.device.RasterizerState = rs;

            GameScreen.effect.Texture = floorTex;
            GameScreen.effect.TextureEnabled = true;

            GameScreen.effect.EnableDefaultLighting();
            GameScreen.effect.SpecularColor = new Vector3(0.005f, 0.005f, 0.01f);
            GameScreen.effect.DiffuseColor = new Vector3(0.2f, 0.2f, 0.2f);

            GameScreen.effect.FogEnabled = true;
            GameScreen.effect.FogColor = new Vector3(0, 0, 0);
            GameScreen.effect.FogStart = 4.0f;
            GameScreen.effect.FogEnd = 8.0f;

            GameScreen.effect.World = Matrix.Identity;

            GameScreen.effect.CurrentTechnique.Passes[0].Apply();

            foreach (Face f in faces)
                f.Render();

            Basic.device.RasterizerState = rs2;
        }
    }


}
